<template>
  <div class="vendor_box" v-loading="signalsRadio1.gysloading" element-loading-text="加载中...">
    <Totalarticles v-if="signalsRadio1.routerPush == 'search' && signalsRadio1.title.title != ''
    " />
    <div class="totalar" v-if="signalsRadio1.routerPush == 'details'">
      <div v-if="signalsRadio1.routerdetails == '2'">为您找到<span class="activeClor">{{ signalsRadio1.daochusupTotal
          }}</span>家供应商</div>

    </div>
    <div style=" min-height: 200px" v-if="signalsRadio1.total > 0">
      <div class="vendor" v-for="item in signalsRadio1.suppliersLiss" :key="item.doc_count">
        <div>
          <!-- <img width="60px" src="@/assets/img/gys.png" alt="" /> -->
          <img width="60px" src="../../../../assets/newimg/gys.png" alt="" />
        </div>
        <div style="flex: 1; margin-left: 10px">
          <div class="vendor_cen">
            <div class="vendor_h" @click="gysClick(item.key)">
              <span v-html="item.key"></span>
            </div>
            <div>
              <span class="origin">最近中标 {{ timestamp(item.max_time?.value) }} </span><span class="origin">中标 {{
                item.doc_count }}次</span><span class="origin">中标总金额 {{ money(item.color_sum_price?.value) }}
              </span>
            </div>
          </div>
          <div class="omission">
            <span style="color: #a9b1be">中标产品：</span>
            <span v-for="ele in item.field1Values.buckets" :key="ele"
              :class="{ resad: signalsRadio1.title.title == ele.key }">
              {{ ele.key }},</span>
          </div>
        </div>
      </div>
    </div>
    <!-- v-if="signalsRadio1.routerPush == 'search'" -->
    <Pagination ref="pagination" v-if="signalsRadio1.routerPush == 'search' && bx_center !== 1" />

    <Paginations v-if="signalsRadio1.routerPush == 'details' && bx_center !== 1" />
    <Vips v-if="signalsRadio1.suppliersLiss.length > 0 && bx_center == 1" />
    <!-- {{ bx_center }} -->
    <div v-if="signalsRadio1.suppliersLiss.lenght == 0" style="background-color: white; margin: 15px 0;">
      <el-empty description="暂无数据" />
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, reactive } from "vue";
import { search_read } from "@/Api/shoop/index.js";
import { useRadio1Store } from "@/pain/search/search";
import { timestamp, money } from "@/utils/index";
import Totalarticles from "../totalarticles/index.vue";
import Pagination from "@/components/pagination/index.vue";
import Paginations from "@/components/daochuPages/index.vue";
import Vips from "@/components/vipts/index.vue";
import { decrypt } from "@/utils/index";
import { useCounterStore } from "@/pain/login/login";
const useRouters = useCounterStore();
const signalsRadio1 = useRadio1Store();
import { userInfo } from '@/Api/api.js'
import { useRouter } from "vue-router";
const router = useRouter();
const bx_center = ref(0)
const tokens = localStorage.getItem("token");
let token = reactive({});
const ids = ref()
if (tokens) {
  userInfo().then(rex => {
    token.value = rex.data.data
    ids.value = rex.data.data.level_id
    search_read().then((res) => {
      if (res.data.data.gongy_center.indexOf(ids.value.toString()) == '-1') {
        bx_center.value = 1
      } else {
        bx_center.value = 0
      }
    });
  })
} else {
  ids.value = 0
}





const gysClick = (data) => {
  if (!localStorage.getItem("token")) {
    return (useRouters.uselogin = true);
  }
  if (signalsRadio1.routerPush == "search") {
    const href = router.resolve({
      path: "/disposition",
      query: {
        id: signalsRadio1.id,
        name: data.replace(/<[^>]+>/g, ""),
      },
    });
    window.open(href.href, "_blank");
  }
};

const gysshuju = () => {
  if (signalsRadio1.routerPush == "details") {
    let daochu = JSON.parse(localStorage.getItem("daochu"));
    const ditu = JSON.parse(localStorage.getItem("ditu"));
    let list = {
      ...daochu,
      ...ditu,
    };
    signalsRadio1.T_getsuppliers(list);
  }
};
gysshuju()
onMounted(() => { });

// const pagination = ref(null);
// pagination.value.currentPage
// pagination.value.pageSize
</script>

<style lang="scss" scoped>
.totalar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  padding: 0 20px;
  background-color: #fff;

  .totalar_right {
    display: flex;
  }

  .daochu1 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 30px;
    margin-left: 15px;
    font-size: 14px;
    border: 1px solid #6675FF;
    border-radius: 4px;
    color: #6675FF;
  }
}

.origin {
  height: 20px;
  line-height: 24px;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: #fe8d03;
  color: #fff;
  margin-left: 10px;
  font-size: 12px;
}

.resad {
  color: red;
}

.vendor_box {
  background-color: #fff;

  //
  .vendor {
    display: flex;
    padding: 20px;
    border-bottom: 1px solid #eeeeee;
    cursor: pointer;

    &:hover {
      background-color: #eeeeee;
    }
  }

  .vendor_cen {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;

    .vendor_h {
      margin-top: 5px;
      max-width: 480px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-size: 16px;
      color: #333333;
    }
  }

  .omission {
    width: 1090px;
    text-align: left;
    font-size: 14px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}
</style>
